var datatable;

$(function(){
		var tpTableColums = [//定义列
		     	            {
		     					"mData":"uuid",
		     					"sClass": "center",
		     					"bSortable": false,
		     					"mRender" : function(data, type, row) {
		     						return '<div class="action-buttons"><a class="red" href="javascript:del(\''+data+'\',\''+row.tpName+'\')"><i class="icon-trash bigger-130"></i></a><a  href="javascript:editTp(\''+data+'\')"><i class="icon-pencil bigger-130"></i></a></div>';	
		     					}
		     	            },
		     	            {"mData":"tpName"},
		     	            {"mData": "prjTypeName"},
		     	    ];
 	    //初始化dataTable
 		datatable = $('#tpTable').dataTable({
 	    	'sAjaxSource': ctx+'/pm/tp/queryTp.do',	//请求数据源 
 			'bServerSide':true,							//是否启动服务器端数据导入
 			"bLengthChange" : false,
 			"bInfo" : true,
 			"bPaginate" : true,
 	        'bFilter': false,                       	//是否使用内置的过滤功能。
 	        'aoColumns': tpTableColums,
 	         "sDom": '<"toolbar">frtip', 
 	         "oLanguage": oLanguage
 		});
	
});


	//查询
	function queryTp() {	
		var oSettings = datatable.fnSettings();
		oSettings._iDisplayStart = 0;
		datatable.fnClearTable(0); //清空数据
		datatable.fnDraw(); //重新加载数据 
	}




	//删除提示的方法
	function del(uuid,prjName){
		Otod.Msg.confirm('您确定要删除【'+prjName+'】?',"删除项目模板" , delOk);
			
		function delOk(){
			Otod.ajax({
				url:ctx + "/pm/tp/delTp.do?uuid="+uuid,
			    type: "GET",
			    successFn: function(data) {
			    	queryTp();
			    }
			});
		}
		
	}


	


	//修改
	function editTp(uuid){
		window.location.href=ctx+"/jsp/pm/prj/stepTp.jsp?tpId="+uuid;
	}
	